﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QLThuVien
{
    class PhieuMuon
    {
         string maPM, madg , manv;
        DateTime ngaymuon;
        
        public PhieuMuon() { }

        public PhieuMuon(string maPM, string madg, string manv,DateTime ngaymuon)
        {
            this.maPM = maPM;
            this.madg = madg;            
            this.manv = manv;
            this.ngaymuon = ngaymuon;
            
        }
        #region cac phuong thuc set
        public void set_maPM(string mathe)
        {
            this.maPM = mathe;
        }

        public void set_madg(string madg)
        {
            this.madg = madg;
        }       

        public void set_manv(string manv)
        {
            this.manv = manv;
        }

        public void set_ngaymuon(DateTime ngaymuon)
        {
            this.ngaymuon = ngaymuon;
        }

        
        #endregion

        #region cac phuong thuc get

        public string get_maPM()
        {
            return maPM;
        }

        public string get_madg()
        {
            return madg;
        }

        public string get_manv()
        {
            return manv;
        }
                
        public DateTime get_ngaymuon()
        {
            return ngaymuon;
        }

        
        #endregion

        public bool taomoiphieumuon()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();         
            if (txdl.thucthitruyvan("INSERT INTO PHIEUMUON VALUES('" + maPM + "','" + madg + "','" + manv + "','" + ngaymuon +"')")==1)//,'" + ngaymuon + "','" + ngayhethantra + "',NULL,NULL,NULL,NULL)") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else
            {
                KetNoi.closeconnect();
                return false;
            }
        }
        
        public bool xoa()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            if (txdl.thucthitruyvan("delete from PHIEUMUON where MAPHIEU='" + maPM + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else
            {
                KetNoi.closeconnect();
                return false;
            }
        }

       
    }
}
